// mod application;
// use application::Application;

// fn main() {
//     let mut app = Application::new("empty");
//     app.init("囧囧西游之大闹天宫", 1024, 768);
//     app.run();
//     println!("finished...");
// }

use imgui::*;
extern crate glium;

mod support;

struct Person<'a> {
    pub name: &'a String,
}

impl<'a> Person<'a> {
    pub fn new(name: &'a String) -> Person<'a> {
        Person { name }
    }
}

impl<'a> std::fmt::Display for Person<'_> {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "Person(name: {})", self.name)
    }
}

fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {
    if x.len() > y.len() {
        x
    } else {
        y
    }
}
#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test1() {
        let lstr;
        let str1 = "a111".to_string();
        lstr = longest(str1.as_str(), "b22");
        assert!(lstr.eq(str1.as_str()), "longest test");
    }
    #[test]
    #[should_panic(expected = "Guess value must be less than or equal to 100")]
    fn panic_test() {
        panic!("it panic !!!");
    }
}

fn main() {
    let lstr;
    let str1 = "a111".to_string();
    lstr = longest(str1.as_str(), "b22");
    println!("longest str is: {}", lstr);

    let mut p: Option<Person> = None;
    // {
    let h = String::from("hello");
    p = Some(Person::new(&h));
    // }
    if let Some(pp) = p {
        println!("pp name is: {}", pp);
    }

    // let system = support::init("囧囧西游之大脑天宫", 1024f64, 768f64);
    // system.main_loop(move |run, ui| {
    //     Window::new(im_str!("Hello world"))
    //         .opened(run)
    //         .size([300.0, 130.0], Condition::FirstUseEver)
    //         .build(ui, || {
    //             ui.text(im_str!("Hello world!"));
    //             ui.text(im_str!("こんにちは世界！"));
    //             ui.text(im_str!("你好，世界！"));
    //             ui.text(im_str!("This...is...imgui-rs!"));
    //             ui.separator();
    //             let mouse_pos = ui.io().mouse_pos;
    //             ui.text(format!(
    //                 "Mouse Position: ({:.1},{:.1})",
    //                 mouse_pos[0], mouse_pos[1]
    //             ));
    //         });
    //     //绘制图形
    // });
    // system;
}
